/* Copyright 2001,2002,2003 NAH6 BV
 * All Rights Reserved
 *
 *  $Header: /var/lib/cvs/secphone/ui/rng/fortuna/fnaEntropySource.h,v 1.3 2003/11/21 12:39:24 itsme Exp $
 *
 *
 */


#ifndef __FNAENTROPYSOURCE_H__

#include "fnaAccumulator.h"

//--------------------------------------------------------------------------

class EntropySource {
public:
    EntropySource();

    virtual ~EntropySource();

    void SetParams(Accumulator::sourcenumber_t nr, Accumulator& prng);

    // must be implemented by source subclass
    virtual void HandleSource()=0;
    virtual bool IsPolledSource() const=0;
    virtual const char* name() const=0;

    HANDLE GetEvent() const;

protected:
    void AddRandom(const ByteVector& data);

    // may be overridden for source that want to only use pool 0.
    virtual Accumulator::poolnumber_t NextPoolNr();

    void SignalNewData();

private:
    Accumulator::poolnumber_t m_poolnr;
    Accumulator::sourcenumber_t m_sourcenr;
    
    HANDLE m_event;

    Accumulator* m_accu;

};


#define __FNAENTROPYSOURCE_H__
#endif
